#!/usr/bin/env perl
use strict;
use warnings;
use Test::More tests => 3;
use lib 'tests/search';
use AIR2TestUtils;    # sets lib path
use AIR2::Searcher::Sources;
use AIR2::Searcher::Sources::Engine;
use Data::Dump qw( dump );
use JSON::XS;

SKIP: {

    if ( !AIR2TestUtils::search_env_ok() ) {
        skip "The search env does not look sane. Skipping all tests", 3; 
    }

    my $authz = AIR2TestUtils::dummy_authz();

    ok( my $searcher = AIR2::Searcher::Sources->new(), "new searcher" );

    ok( my $results = $searcher->do_search(
            {   q        => 'test',
                auth_tkt => $authz,
                u        => 1,
                p        => 100000,
            }
        ),
        "get results"
    );

    #diag( dump $results );

    cmp_ok( scalar( @{ $results->{results} } ),
        '==', $results->{total}, "got expected total results" );

}
